﻿@addTagHelper *, WebVella.Erp.Plugins.Core
@addTagHelper *, WebVella.Erp.Web
@addTagHelper *, WebVella.TagHelpers
@using WebVella.Erp.Web.Utils;
@using WebVella.Erp.Api.Models;
@using WebVella.Erp.Web.Models;
@using WebVella.Erp.Plugins.Project.Components;
@using WebVella.TagHelpers.Models;
@{
	var options = (PcProjectWidgetBudgetChart.PcProjectWidgetBudgetChartOptions)ViewBag.Options;
	var datasets = (List<WvChartDataset>)ViewBag.Datasets;
	var budgetResult = (EntityRecord)ViewBag.BudgetResult;
	var billableHoursInt = Math.Round((decimal)budgetResult["billed_hours"],1);
	var nonbillableHoursInt = Math.Round((decimal)budgetResult["nonbilled_hours"],1);
	var estimatedHoursInt = Math.Round((decimal)budgetResult["estimated_hours"],1);
	var hoursLeft = estimatedHoursInt - (billableHoursInt + nonbillableHoursInt);
	var budgetLeft = Math.Round((decimal)budgetResult["budget_left"], 1);
}
<wv-row flex-vertical-alignment="Center" class="w-100 h-100" no-gutters="true">
	<wv-column class="flex-grow-0">
		<wv-chart type="Doughnut" datasets="@datasets" width="100px" height="100px"></wv-chart>		
	</wv-column>
	<wv-column class="flex-grow-1 pl-4">
		<wv-row class="mb-2">
			<wv-column>
				<div>Billable</div>
				<div><strong><i class="fas fa-circle go-green"></i> @billableHoursInt h</strong></div>		
			</wv-column>
			<wv-column>
				<div>Estimation left</div>
				<div><strong class="@(hoursLeft >= 0 ? "" : "go-red")">@hoursLeft h</strong></div>				
			</wv-column>
		</wv-row>
		<wv-row class="mb-2">
			<wv-column>
				<div>Non-billable</div>
				<div><strong><i class="fas fa-circle go-light-blue"></i> @nonbillableHoursInt h</strong></div>
			</wv-column>
			<wv-column>
				<div>Budget left</div>
				<div>
					<strong class="@(budgetLeft >= 0 ? "" : "go-red")">
						@budgetLeft h
					</strong>
				</div>					
			</wv-column>
		</wv-row>
	</wv-column>
</wv-row>